/***
 * 此文件创建search组件的小仓库
 */

import {reqSearchData} from '@/api'

const actions = {
    async getSearchList({commit},data){
        let result = await reqSearchData(data);
        if(result.code === 200){
            commit('GETSEARCHLIST',result.data)
        }
    }
};

const mutations = {
    GETSEARCHLIST(state,searchData){
        state.searchData = searchData
    }
};

const state = {
    searchData:{}
};

//vue项目中,getters为处理简化state中的数据,使组件使用简单
const getters = {
    //商品信息列表
    goodsList(state){
        return state.searchData.goodsList
    },
    //品牌列表
    trademarkList(state){
        return state.searchData.trademarkList
    },
    //平台属性列表
    attrsList(state){
        return state.searchData.attrsList
    }
};

export default {
    actions,
    mutations,
    state,
    getters
}